<template>
  <div class="wrap">
    <div class="header">
      <div class="left">
        <div style="font-weight: bold">异常商品</div>
      </div>
      <div class="right">
        <export-button :func="getExceptPickingOrder" :query-params="{
          export: 1,
        }"></export-button>
      </div>
    </div>
    <div class="content">
      <el-table
        :data="data"
        row-key="id"
        border
        v-loading="loading"
      >
        <el-table-column
          prop="pickingNo"
          label="拣货需求表"
          align="center"
          width="200"
        >
        </el-table-column>
        <el-table-column
          prop="num"
          label="商品封面"
          align="center"
          width="110"
        >
          <template slot-scope="{row}">
            <div class="img-box img-one">
              <img :src="row.goodsImage" alt="">
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="orderId"
          label="订单编号"
          align="center"
          width="200"
        >
        </el-table-column>
        <el-table-column
          prop="userAccount"
          label="用户名"
          align="center"
          min-width="200"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="showName"
          label="店铺名"
          align="center"
          min-width="200"
        >
        </el-table-column>
        <el-table-column
          prop="goodsTitle"
          label="商品标题"
          align="left"
          min-width="250"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          prop="goodsId"
          label="Listing ID"
          align="center"
          min-width="200"
        >
        </el-table-column>
        <el-table-column
          prop="variationSku"
          label="SKU"
          align="center"
          min-width="200"
        >
        </el-table-column>
        <el-table-column
          prop="attributes"
          label="变体属性"
          align="left"
          min-width="300"
        >
          <template slot-scope="{row}">
            <div class="goods-SKU-info">
                <span
                  v-for="attr in row.attributes"
                  :key="attr.name"
                  class="attr"
                >
                  {{attr.name}} : {{attr.value}}
                  <span class="attr-link"> | </span>
                </span>
            </div>
          </template>
        </el-table-column>
        <el-table-column
          prop="num"
          label="数量"
          align="center"
          width="100"
        >
        </el-table-column>
        <el-table-column
          prop="num"
          label="操作"
          align="left"
          min-width="200"
        >
          <template slot-scope="{row}">
            <el-button class="mgr10" @click="cancelMark(row)" type="danger">取消标记</el-button>
          </template>
        </el-table-column>

      </el-table>
      <div class="table-footer-tips">
        <p>如存在商品无法拣货的情况，请与用户沟通确认确认对应商品的信息。当商品信息一致时，即可取消该异常标记</p>
        <p>当订单被取消时，该订单中所有商品的异常标记会被自动清除</p>
      </div>

    </div>
  </div>
</template>

<script>
import {cancelExceptPicking, getExceptPickingOrder, savePickingOrder} from "@/api/picking";
import ExportButton from "@/views/order/components/ExportButton.vue";

export default {
  name: "packList",
  components: {ExportButton},
  data(){
    return {
      queryParams: {
        page: 1,
        pageSize: 20,
        time: [],
        status: '',
      },
      data: [

      ],
      loading: false,
      total: 0,
    };
  },
  created() {
    this.getData()
  },
  methods:{
    getExceptPickingOrder,
    getData(){
      this.loading = true;
      getExceptPickingOrder()
        .then(res=>{
          this.loading = false
          this.data = res.data
        })
    },
    cancelMark(row){
      this.$warning(`取消后，当前记录将被完全清除？`,{
        title: '确认取消异常标记？',
      })
        .then(() => {

          cancelExceptPicking(row.id)
            .then(res=>{
              this.$successMessage('保存成功')
              this.getData()
              this.$store.dispatch('user/getInfo');
            })
        })
    }
  }
}
</script>

<style scoped lang="scss">
.wrap {
  padding: 30px 30px;

  .header {
    display: flex;
    justify-content: space-between;
  }

  .content {
    padding: 0 0 0;
    margin-top: 20px;
  }
}
.table-footer-tips{
  p{
    margin: 0;
    padding: 0;
    font-size: 12px;
  }
}
</style>
